package com.bawei.mdm2207alast.model.db

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

/**
 * 作者：赵亮
 * 时间：2024/12/24 11:51
 * 功能：请假相关的数据操作
 */
@Dao
interface AskDao {

    /**
     * 提交请假
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(askEntity: AskEntity): Long

    /**
     * 根据用户id查询请假列表
     */
    @Query("select * from askentity where uid=:uid order by time desc")
    fun selectByUid(uid: Long): List<AskEntity>

    /**
     * 查询所有待审批的列表
     */
    @Query("select * from askentity where status = '已提交'")
    fun selectNoApprove(): List<AskEntity>

    /**
     * 更新数据
     */
    @Update
    fun update(askEntity: AskEntity)

    /**
     * 根据用户id分页查询
     */
    @Query("select * from askentity where uid=:uid order by start desc limit(:page - 1)*:size,:page * :size")
    fun selectByUid(uid: Long, page: Int, size: Int): List<AskEntity>
}